package com.bll;

import java.util.ArrayList;

import com.dal.PriorityDAO;
import com.model.Priority;

public class PriorityBLO {
	public enum PriorityEnum {
		Coding(1), Syntax(2);

		private final int id;

		PriorityEnum(int i) {
			id = i;
		}

		PriorityEnum parse(int i) throws Exception {
			for (PriorityEnum e : PriorityEnum.values()) {
				if (e.id == id) {
					return e;
				}
			}
			return null;
		}
	}

	private int priorityId;
	private String priorityName;

	public PriorityBLO(int PriorityId, String PriorityName) {
		super();
		this.priorityId = PriorityId;
		this.priorityName = PriorityName;
	}

	// Methods

	public static ArrayList<PriorityBLO> loadAllPriority() {
		ArrayList<Priority> list = new PriorityDAO().select();
		return getPriorityBLOListFromEntityList(list);
	}

	// Internal Methods
	private static ArrayList<PriorityBLO> getPriorityBLOListFromEntityList(
			ArrayList<Priority> list) {
		ArrayList<PriorityBLO> PriorityBLOlist = new ArrayList<PriorityBLO>();
		for (Priority Priority : list) {
			PriorityBLOlist.add(getPriorityBLOFromEntity(Priority));
		}
		return PriorityBLOlist;
	}

	private static PriorityBLO getPriorityBLOFromEntity(Priority entity) {
		return new PriorityBLO(entity.getPriorityID(), entity.getPriorityName());
	}

	// Utility Methods
	public String getDisplayText() {
		return priorityName;
	}

	/**
	 * @return the PriorityId
	 */
	public int getPriorityId() {
		return priorityId;
	}

	/**
	 * @param PriorityId
	 *            the PriorityId to set
	 */
	public void setPriorityId(int PriorityId) {
		this.priorityId = PriorityId;
	}

	/**
	 * @return the PriorityName
	 */
	public String getPriorityName() {
		return priorityName;
	}

	/**
	 * @param PriorityName
	 *            the PriorityName to set
	 */
	public void setPriorityName(String PriorityName) {
		this.priorityName = PriorityName;
	}

}
